const Router = require('koa-router');
const router = new Router();
const tool = require('../../tools/tool')
const {db, QueryTypes} = require("../../models/db");

// 保存送货路线区域
router.post('/deliver/getCargoById', async ctx => {
    let tenantId = ctx.user.tenantId;
    let id = ctx.request.body.id;
    let sql = `SELECT b.billNo,b.billDate,b.id,b.billType,b.transTypeName,b.buName,b.address,b.invName,b.unit,b.price,b.qty from cargo_invoice a inner join v_invoice_detail b on a.iid=b.id  
        where a.cargoId=${id} and a.tenantId=${tenantId} order by a.cargoId,b.invId `
    let list = await db.query(sql, {type: QueryTypes.SELECT})
    return ctx.suc('', list);
})


module.exports = router;
